class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-12-21",
      revision: "00cc9f489e3025d35b6f8229ebb654a3e18657ba"
  version "2021-12-21"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "8c0ab5a830f6efc8688075a6363cd1d363ca5b1f30ef32340fce69b03023532d"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "58d7cf2f00c0dd411e2e166edbd8c1f876ddbc734d47a5a565f1ca1aad494eec"
    sha256 cellar: :any_skip_relocation, monterey:       "d10463a2f21ca442e86a157f37d30eaa03e486290ccb240447661161b9a0dd5b"
    sha256 cellar: :any_skip_relocation, big_sur:        "76700b66881681a5a5b2640ec5cffa4a6ee30f3b174fe19e3cfa8f9e749a5ee6"
    sha256 cellar: :any_skip_relocation, catalina:       "c6e7727578e129f7c9269d84858cbfd33b33da6c1adb4aa596d8fb101fe23f80"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "90cccf81326c9741408234af7e0a5d6ced60b8163c3865d451a336de3f24dcd1"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
